package weaver.interfaces.jjy.duss.hr;

import com.sap.mw.jco.JCO;
import weaver.general.BaseBean;
import weaver.interfaces.jjy.duss.util.SAPConnPool;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title: ecology-9-demo
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-05-09
 * @Description: 编制上报(编制上报回传SAP)
 * @ModifyLog:
 **/

public class ZFM_HR_BZ_SEL {
    public static JCO.Table execute (Map<String, String> map) {
        SAPConnPool SAPConn = new SAPConnPool();
        JCO.Client myConnection = SAPConn.getConnection();
        JCO.Function bapi = SAPConn.excuteBapi("ZFM_HR_BZ_SEL");
        BaseBean baseBean = new BaseBean();
        JCO.ParameterList input = bapi.getImportParameterList();//输入参数和结构处理
        JCO.ParameterList inputtable = bapi.getTableParameterList();//输入表的处理
        baseBean.writeLog("in----ZFM_HR_BZ_SEL");
        //输入参数
        input.setValue(map.get("DATUM"), "IV_DATUM");//查询日期
        input.setValue(map.get("BMBM"), "IV_BMBM");//部门编码
        input.setValue(map.get("BZLX"), "IV_BZLX");//编制类型
        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList Table00 = bapi.getTableParameterList();//输出表的处理
        //返回处理结果以及日志
        JCO.Table tabs = Table00.getTable("ET_DATA");
        baseBean.writeLog("SPA_COUNTS:" + tabs.getNumRows());
        //返回处理结果以及日志
        JCO.Structure stu = out.getStructure("EV_OUTPUT");
        Map<String, String> mapreturn = new HashMap<>();
        String flag = (String) stu.getValue("ZFLAG");
        String message = (String) stu.getValue("ZMESG");
        mapreturn.put("flag", flag);
        mapreturn.put("message", message);
        baseBean.writeLog(mapreturn.toString());
        JCO.releaseClient(myConnection);
        return tabs;
    }

    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("DATUM" , "20200601");       //OA主键
        map.put("BMBM" , "10003095");      //生效日期
        map.put("BZLX" , "2");            //编制类型
        ZFM_HR_BZ_SEL bz_zb = new ZFM_HR_BZ_SEL();
        JCO.Table resultMap = bz_zb.execute(map);
        System.out.println(resultMap.getNumRows());

    }
}
